package com.cn.pack.controller;

import com.cn.pack.po.Animal;
import com.cn.pack.service.CollapsingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Future;

@RestController
public class CollapsingController {

    @Autowired
    private CollapsingService collapsingService;

    @RequestMapping(path = "/animal/get")
    public String getAnimal() throws Exception {
        Future<Animal> future1 = collapsingService.collapsing(101);
        Future<Animal> future2 = collapsingService.collapsing(111);
        Future<Animal> future3 = collapsingService.collapsing(122);
        System.out.println("future1 = " + (future1 == null || future1.get() == null ? "error" : future1.get().getName()));
        System.out.println("future2 = " + (future2 == null || future2.get() == null ? "error" : future2.get().getName()));
        System.out.println("future3 = " + (future3 == null || future3.get() == null ? "error" : future3.get().getName()));
        return "SUCCESS";
    }
}
